blob: 1a7377ce30b68905176fb2af33ee72bf682b86ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<script>
import { goto } from '$app/navigation';
/** @type {import('./$types').PageData} */
export let data;
console.log(data);
let copyPromise = null;
let timer = 0;
function copy() {
copyPromise = navigator.clipboard.writeText(data.reqJson.Data.Content);
timer = 3;
setTimeout(function() {
for (; timer >= 0 ; timer --);
return
}, 1000)
}
async function del() {
let res = await fetch(`/api/v1/del/${data.id}`, {
method: "DELETE",
})
const resp = await res.json()
console.log(resp)
if ('Code' in resp && resp.Code === 200) {
goto('/')
}
}
</script>
<h2>ID: {data.id}</h2>
{#if timer > 0}
{#await copyPromise}
{:then}
<p>
Successfully copied!
</p>
{:catch error}
<p>
Failed to copy: {error}
</p>
{/await}
{/if}
<button on:click={copy}>Copy to clipboard!</button>
<button on:click={del}>Delete</button>
<pre id="content" class="code">{data.reqJson.Data.Content}</pre>
<style>
/* TODO: Figure out why the styles don't get propagated down here
from the +layout up above */
.code {
color: #000;
background-color: #FFFFEA;
display: block;
padding: 10px;
border: 1px solid;
line-height: 1.1;
overflow: auto;
border: 1px solid;
padding: 2px;
font-size: .8em;
font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace";
}
</style>
|